home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / gcc.info-2 (.txt) < prev    next >
GNU Info File  |  1994-07-14  |  48KB  |  911 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: Overall Options,  Next: Invoking G++,  Prev: Option Summary,  Up: Invoking GCC
  23. Options Controlling the Kind of Output
  24. ======================================
  25.    Compilation can involve up to four stages: preprocessing, compilation
  26. proper, assembly and linking, always in that order.  The first three
  27. stages apply to an individual source file, and end by producing an
  28. object file; linking combines all the object files (those newly
  29. compiled, and those specified as input) into an executable file.
  30.    For any given input file, the file name suffix determines what kind
  31. of compilation is done:
  32. `FILE.c'
  33.      C source code which must be preprocessed.
  34. `FILE.i'
  35.      C source code which should not be preprocessed.
  36. `FILE.ii'
  37.      C++ source code which should not be preprocessed.
  38. `FILE.m'
  39.      Objective-C source code.  Note that you must link with the library
  40.      `libobjc.a' to make an Objective-C program work.
  41. `FILE.h'
  42.      C header file (not to be compiled or linked).
  43. `FILE.cc'
  44. `FILE.cxx'
  45. `FILE.cpp'
  46. `FILE.C'
  47.      C++ source code which must be preprocessed.  Note that in `.cxx',
  48.      the last two letters must both be literally `x'.  Likewise, `.C'
  49.      refers to a literal capital C.
  50. `FILE.s'
  51.      Assembler code.
  52. `FILE.S'
  53.      Assembler code which must be preprocessed.
  54. `OTHER'
  55.      An object file to be fed straight into linking.  Any file name
  56.      with no recognized suffix is treated this way.
  57.    You can specify the input language explicitly with the `-x' option:
  58. `-x LANGUAGE'
  59.      Specify explicitly the LANGUAGE for the following input files
  60.      (rather than letting the compiler choose a default based on the
  61.      file name suffix).  This option applies to all following input
  62.      files until the next `-x' option.  Possible values for LANGUAGE
  63.      are:
  64.           c  objective-c  c++
  65.           c-header  cpp-output  c++-cpp-output
  66.           assembler  assembler-with-cpp
  67. `-x none'
  68.      Turn off any specification of a language, so that subsequent files
  69.      are handled according to their file name suffixes (as they are if
  70.      `-x' has not been used at all).
  71.    If you only want some of the stages of compilation, you can use `-x'
  72. (or filename suffixes) to tell `gcc' where to start, and one of the
  73. options `-c', `-S', or `-E' to say where `gcc' is to stop.  Note that
  74. some combinations (for example, `-x cpp-output -E' instruct `gcc' to do
  75. nothing at all.
  76.      Compile or assemble the source files, but do not link.  The linking
  77.      stage simply is not done.  The ultimate output is in the form of an
  78.      object file for each source file.
  79.      By default, the object file name for a source file is made by
  80.      replacing the suffix `.c', `.i', `.s', etc., with `.o'.
  81.      Unrecognized input files, not requiring compilation or assembly,
  82.      are ignored.
  83.      Stop after the stage of compilation proper; do not assemble.  The
  84.      output is in the form of an assembler code file for each
  85.      non-assembler input file specified.
  86.      By default, the assembler file name for a source file is made by
  87.      replacing the suffix `.c', `.i', etc., with `.s'.
  88.      Input files that don't require compilation are ignored.
  89.      Stop after the preprocessing stage; do not run the compiler
  90.      proper.  The output is in the form of preprocessed source code,
  91.      which is sent to the standard output.
  92.      Input files which don't require preprocessing are ignored.
  93. `-o FILE'
  94.      Place output in file FILE.  This applies regardless to whatever
  95.      sort of output is being produced, whether it be an executable file,
  96.      an object file, an assembler file or preprocessed C code.
  97.      Since only one output file can be specified, it does not make
  98.      sense to use `-o' when compiling more than one input file, unless
  99.      you are producing an executable file as output.
  100.      If `-o' is not specified, the default is to put an executable file
  101.      in `a.out', the object file for `SOURCE.SUFFIX' in `SOURCE.o', its
  102.      assembler file in `SOURCE.s', and all preprocessed C source on
  103.      standard output.
  104.      Print (on standard error output) the commands executed to run the
  105.      stages of compilation.  Also print the version number of the
  106.      compiler driver program and of the preprocessor and the compiler
  107.      proper.
  108. `-pipe'
  109.      Use pipes rather than temporary files for communication between the
  110.      various stages of compilation.  This fails to work on some systems
  111.      where the assembler is unable to read from a pipe; but the GNU
  112.      assembler has no trouble.
  113. File: gcc.info,  Node: Invoking G++,  Next: C Dialect Options,  Prev: Overall Options,  Up: Invoking GCC
  114. Compiling C++ Programs
  115. ======================
  116.    C++ source files conventionally use one of the suffixes `.C', `.cc',
  117. or `.cxx'; preprocessed C++ files use the suffix `.ii'.  GNU CC
  118. recognizes files with these names and compiles them as C++ programs
  119. even if you call the compiler the same way as for compiling C programs
  120. (usually with the name `gcc').
  121.    However, C++ programs often require class libraries as well as a
  122. compiler that understands the C++ language--and under some
  123. circumstances, you might want to compile programs from standard input,
  124. or otherwise without a suffix that flags them as C++ programs.  `g++'
  125. is a program that calls GNU CC with the default language set to C++,
  126. and automatically specifies linking against the GNU class library
  127. libg++.  (1) On many systems, the script `g++' is also installed with
  128. the name `c++'.
  129.    When you compile C++ programs, you may specify many of the same
  130. command-line options that you use for compiling programs in any
  131. language; or command-line options meaningful for C and related
  132. languages; or options that are meaningful only for C++ programs.  *Note
  133. Options Controlling C Dialect: C Dialect Options, for explanations of
  134. options for languages related to C.  *Note Options Controlling C++
  135. Dialect: C++ Dialect Options, for explanations of options that are
  136. meaningful only for C++ programs.
  137.    ---------- Footnotes ----------
  138.    (1)  Prior to release 2 of the compiler, there was a separate `g++'
  139. compiler.  That version was based on GNU CC, but not integrated with
  140. it.  Versions of `g++' with a `1.XX' version number--for example, `g++'
  141. version 1.37 or 1.42--are much less reliable than the versions
  142. integrated with GCC 2.  Moreover, combining G++ `1.XX' with a version 2
  143. GCC will simply not work.
  144. File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
  145. Options Controlling C Dialect
  146. =============================
  147.    The following options control the dialect of C (or languages derived
  148. from C, such as C++ and Objective C) that the compiler accepts:
  149. `-ansi'
  150.      Support all ANSI standard C programs.
  151.      This turns off certain features of GNU C that are incompatible
  152.      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
  153.      predefined macros such as `unix' and `vax' that identify the type
  154.      of system you are using.  It also enables the undesirable and
  155.      rarely used ANSI trigraph feature, and disallows `$' as part of
  156.      identifiers.
  157.      The alternate keywords `__asm__', `__extension__', `__inline__'
  158.      and `__typeof__' continue to work despite `-ansi'.  You would not
  159.      want to use them in an ANSI C program, of course, but it is useful
  160.      to put them in header files that might be included in compilations
  161.      done with `-ansi'.  Alternate predefined macros such as `__unix__'
  162.      and `__vax__' are also available, with or without `-ansi'.
  163.      The `-ansi' option does not cause non-ANSI programs to be rejected
  164.      gratuitously.  For that, `-pedantic' is required in addition to
  165.      `-ansi'.  *Note Warning Options::.
  166.      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
  167.      is used.  Some header files may notice this macro and refrain from
  168.      declaring certain functions or defining certain macros that the
  169.      ANSI standard doesn't call for; this is to avoid interfering with
  170.      any programs that might use these names for other things.
  171.      The functions `alloca', `abort', `exit', and `_exit' are not
  172.      builtin functions when `-ansi' is used.
  173. `-fno-asm'
  174.      Do not recognize `asm', `inline' or `typeof' as a keyword.  These
  175.      words may then be used as identifiers.  You can use the keywords
  176.      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
  177.      `-fno-asm'.
  178. `-fno-builtin'
  179.      Don't recognize builtin functions that do not begin with two
  180.      leading underscores.  Currently, the functions affected include
  181.      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
  182.      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
  183.      `strlen'.
  184.      GCC normally generates special code to handle certain builtin
  185.      functions more efficiently; for instance, calls to `alloca' may
  186.      become single instructions that adjust the stack directly, and
  187.      calls to `memcpy' may become inline copy loops.  The resulting
  188.      code is often both smaller and faster, but since the function
  189.      calls no longer appear as such, you cannot set a breakpoint on
  190.      those calls, nor can you change the behavior of the functions by
  191.      linking with a different library.
  192.      The `-ansi' option prevents `alloca' and `ffs' from being builtin
  193.      functions, since these functions do not have an ANSI standard
  194.      meaning.
  195. `-trigraphs'
  196.      Support ANSI C trigraphs.  You don't want to know about this
  197.      brain-damage.  The `-ansi' option implies `-trigraphs'.
  198. `-traditional'
  199.      Attempt to support some aspects of traditional C compilers.
  200.      Specifically:
  201.         * All `extern' declarations take effect globally even if they
  202.           are written inside of a function definition.  This includes
  203.           implicit declarations of functions.
  204.         * The newer keywords `typeof', `inline', `signed', `const' and
  205.           `volatile' are not recognized.  (You can still use the
  206.           alternative keywords such as `__typeof__', `__inline__', and
  207.           so on.)
  208.         * Comparisons between pointers and integers are always allowed.
  209.         * Integer types `unsigned short' and `unsigned char' promote to
  210.           `unsigned int'.
  211.         * Out-of-range floating point literals are not an error.
  212.         * Certain constructs which ANSI regards as a single invalid
  213.           preprocessing number, such as `0xe-0xd', are treated as
  214.           expressions instead.
  215.         * String "constants" are not necessarily constant; they are
  216.           stored in writable space, and identical looking constants are
  217.           allocated separately.  (This is the same as the effect of
  218.           `-fwritable-strings'.)
  219.         * All automatic variables not declared `register' are preserved
  220.           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
  221.           variables not declared `volatile' may be clobbered.
  222.         * The character escape sequences `\x' and `\a' evaluate as the
  223.           literal characters `x' and `a' respectively.  Without
  224.           `-traditional', `\x' is a prefix for the hexadecimal
  225.           representation of a character, and `\a' produces a bell.
  226.         * In C++ programs, assignment to `this' is permitted with
  227.           `-traditional'.  (The option `-fthis-is-variable' also has
  228.           this effect.)
  229.      You may wish to use `-fno-builtin' as well as `-traditional' if
  230.      your program uses names that are normally GNU C builtin functions
  231.      for other purposes of its own.
  232.      You cannot use `-traditional' if you include any header files that
  233.      rely on ANSI C features.  Some vendors are starting to ship
  234.      systems with ANSI C header files and you cannot use `-traditional'
  235.      on such systems to compile files that include any system headers.
  236.      In the preprocessor, comments convert to nothing at all, rather
  237.      than to a space.  This allows traditional token concatenation.
  238.      In preprocessor directive, the `#' symbol must appear as the first
  239.      character of a line.
  240.      In the preprocessor, macro arguments are recognized within string
  241.      constants in a macro definition (and their values are stringified,
  242.      though without additional quote marks, when they appear in such a
  243.      context).  The preprocessor always considers a string constant to
  244.      end at a newline.
  245.      The predefined macro `__STDC__' is not defined when you use
  246.      `-traditional', but `__GNUC__' is (since the GNU extensions which
  247.      `__GNUC__' indicates are not affected by `-traditional').  If you
  248.      need to write header files that work differently depending on
  249.      whether `-traditional' is in use, by testing both of these
  250.      predefined macros you can distinguish four situations: GNU C,
  251.      traditional GNU C, other ANSI C compilers, and other old C
  252.      compilers.  *Note Standard Predefined Macros: (cpp.info)Standard
  253.      Predefined, for more discussion of these and other predefined
  254.      macros.
  255.      The preprocessor considers a string constant to end at a newline
  256.      (unless the newline is escaped with `\').  (Without `-traditional',
  257.      string constants can contain the newline character as typed.)
  258. `-traditional-cpp'
  259.      Attempt to support some aspects of traditional C preprocessors.
  260.      This includes the last five items in the table immediately above,
  261.      but none of the other effects of `-traditional'.
  262. `-fcond-mismatch'
  263.      Allow conditional expressions with mismatched types in the second
  264.      and third arguments.  The value of such an expression is void.
  265. `-funsigned-char'
  266.      Let the type `char' be unsigned, like `unsigned char'.
  267.      Each kind of machine has a default for what `char' should be.  It
  268.      is either like `unsigned char' by default or like `signed char' by
  269.      default.
  270.      Ideally, a portable program should always use `signed char' or
  271.      `unsigned char' when it depends on the signedness of an object.
  272.      But many programs have been written to use plain `char' and expect
  273.      it to be signed, or expect it to be unsigned, depending on the
  274.      machines they were written for.  This option, and its inverse, let
  275.      you make such a program work with the opposite default.
  276.      The type `char' is always a distinct type from each of `signed
  277.      char' or `unsigned char', even though its behavior is always just
  278.      like one of those two.
  279. `-fsigned-char'
  280.      Let the type `char' be signed, like `signed char'.
  281.      Note that this is equivalent to `-fno-unsigned-char', which is the
  282.      negative form of `-funsigned-char'.  Likewise, the option
  283.      `-fno-signed-char' is equivalent to `-funsigned-char'.
  284. `-fsigned-bitfields'
  285. `-funsigned-bitfields'
  286. `-fno-signed-bitfields'
  287. `-fno-unsigned-bitfields'
  288.      These options control whether a bitfield is signed or unsigned,
  289.      when the declaration does not use either `signed' or `unsigned'.
  290.      By default, such a bitfield is signed, because this is consistent:
  291.      the basic integer types such as `int' are signed types.
  292.      However, when `-traditional' is used, bitfields are all unsigned
  293.      no matter what.
  294. `-fwritable-strings'
  295.      Store string constants in the writable data segment and don't
  296.      uniquize them.  This is for compatibility with old programs which
  297.      assume they can write into string constants.  The option
  298.      `-traditional' also has this effect.
  299.      Writing into string constants is a very bad idea; "constants"
  300.      should be constant.
  301. `-fallow-single-precision'
  302.      Do not promote single precision math operations to double
  303.      precision, even when compiling with `-traditional'.
  304.      Traditional K&R C promotes all floating point operations to double
  305.      precision, regardless of the sizes of the operands.   On the
  306.      architecture for which you are compiling, single precision may be
  307.      faster than double precision.   If you must use `-traditional',
  308.      but want to use single precision operations when the operands are
  309.      single precision, use this option.   This option has no effect
  310.      when compiling with ANSI or GNU C conventions (the default).
  311. File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
  312. Options Controlling C++ Dialect
  313. ===============================
  314.    This section describes the command-line options that are only
  315. meaningful for C++ programs; but you can also use most of the GNU
  316. compiler options regardless of what language your program is in.  For
  317. example, you might compile a file `firstClass.C' like this:
  318.      g++ -g -felide-constructors -O -c firstClass.C
  319. In this example, only `-felide-constructors' is an option meant only
  320. for C++ programs; you can use the other options with any language
  321. supported by GNU CC.
  322.    Here is a list of options that are *only* for compiling C++ programs:
  323. `-fall-virtual'
  324.      Treat all possible member functions as virtual, implicitly.  All
  325.      member functions (except for constructor functions and `new' or
  326.      `delete' member operators) are treated as virtual functions of the
  327.      class where they appear.
  328.      This does not mean that all calls to these member functions will
  329.      be made through the internal table of virtual functions.  Under
  330.      some circumstances, the compiler can determine that a call to a
  331.      given virtual function can be made directly; in these cases the
  332.      calls are direct in any case.
  333. `-fdollars-in-identifiers'
  334.      Accept `$' in identifiers.  You can also explicitly prohibit use of
  335.      `$' with the option `-fno-dollars-in-identifiers'.  (GNU C++
  336.      allows `$' by default on some target systems but not others.)
  337.      Traditional C allowed the character `$' to form part of
  338.      identifiers.  However, ANSI C and C++ forbid `$' in identifiers.
  339. `-felide-constructors'
  340.      Elide constructors when this seems plausible.  With this option,
  341.      GNU C++ initializes `y' directly from the call to `foo' without
  342.      going through a temporary in the following code:
  343.           A foo ();
  344.           A y = foo ();
  345.      Without this option, GNU C++ (1) initializes `y' by calling the
  346.      appropriate constructor for type `A'; (2) assigns the result of
  347.      `foo' to a temporary; and, finally, (3) replaces the initial value
  348.      of `y' with the temporary.
  349.      The default behavior (`-fno-elide-constructors') is specified by
  350.      the draft ANSI C++ standard.  If your program's constructors have
  351.      side effects, `-felide-constructors' can change your program's
  352.      behavior, since some constructor calls may be omitted.
  353. `-fenum-int-equiv'
  354.      Permit implicit conversion of `int' to enumeration types.  Normally
  355.      GNU C++ allows conversion of `enum' to `int', but not the other
  356.      way around.
  357. `-fexternal-templates'
  358.      Produce smaller code for template declarations, by generating only
  359.      a single copy of each template function where it is defined.  To
  360.      use this option successfully, you must also mark all files that
  361.      use templates with either `#pragma implementation' (the
  362.      definition) or `#pragma interface' (declarations).  *Note
  363.      Declarations and Definitions in One Header: C++ Interface, for more
  364.      discussion of these pragmas.
  365.      When your code is compiled with `-fexternal-templates', all
  366.      template instantiations are external.  You must arrange for all
  367.      necessary instantiations to appear in the implementation file; you
  368.      can do this with a `typedef' that references each instantiation
  369.      needed.  Conversely, when you compile using the default option
  370.      `-fno-external-templates', all template instantiations are
  371.      explicitly internal.
  372.      You do not need to specify `-fexternal-templates' when compiling a
  373.      file that does not define and instantiate templates used in other
  374.      files, even if your file *uses* templates defined in other files
  375.      that are compiled with `-fexternal-templates'.  The only side
  376.      effect is an increase in object size for each file that you
  377.      compile without `-fexternal-templates'.
  378. `-fhandle-signatures'
  379.      Recognize the `signature' and `sigof' keywords for specifying
  380.      abstract types.  The default (`-fno-handle-signatures') is not to
  381.      recognize them.  *Note Type Abstraction using Signatures: C++
  382.      Signatures.
  383. `-fmemoize-lookups'
  384. `-fsave-memoized'
  385.      Use heuristics to compile faster.  These heuristics are not
  386.      enabled by default, since they are only effective for certain
  387.      input files.  Other input files compile more slowly.
  388.      The first time the compiler must build a call to a member function
  389.      (or reference to a data member), it must (1) determine whether the
  390.      class implements member functions of that name; (2) resolve which
  391.      member function to call (which involves figuring out what sorts of
  392.      type conversions need to be made); and (3) check the visibility of
  393.      the member function to the caller.  All of this adds up to slower
  394.      compilation.  Normally, the second time a call is made to that
  395.      member function (or reference to that data member), it must go
  396.      through the same lengthy process again.  This means that code like
  397.      this:
  398.           cout << "This " << p << " has " << n << " legs.\n";
  399.      makes six passes through all three steps.  By using a software
  400.      cache, a "hit" significantly reduces this cost.  Unfortunately,
  401.      using the cache introduces another layer of mechanisms which must
  402.      be implemented, and so incurs its own overhead.
  403.      `-fmemoize-lookups' enables the software cache.
  404.      Because access privileges (visibility) to members and member
  405.      functions may differ from one function context to the next, G++
  406.      may need to flush the cache.  With the `-fmemoize-lookups' flag,
  407.      the cache is flushed after every function that is compiled.  The
  408.      `-fsave-memoized' flag enables the same software cache, but when
  409.      the compiler determines that the context of the last function
  410.      compiled would yield the same access privileges of the next
  411.      function to compile, it preserves the cache.  This is most helpful
  412.      when defining many member functions for the same class: with the
  413.      exception of member functions which are friends of other classes,
  414.      each member function has exactly the same access privileges as
  415.      every other, and the cache need not be flushed.
  416. `-fno-strict-prototype'
  417.      Treat a function declaration with no arguments, such as `int foo
  418.      ();', as C would treat it--as saying nothing about the number of
  419.      arguments or their types.  Normally, such a declaration in C++
  420.      means that the function `foo' takes no arguments.
  421. `-fnonnull-objects'
  422.      Assume that objects reached through references are not null.
  423.      Normally, GNU C++ makes conservative assumptions about objects
  424.      reached through references.  For example, the compiler must check
  425.      that `a' is not null in code like the following:
  426.           obj &a = g ();
  427.           a.f (2);
  428.      Checking that references of this sort have non-null values requires
  429.      extra code, however, and it is unnecessary for many programs.  You
  430.      can use `-fnonnull-objects' to omit the checks for null, if your
  431.      program doesn't require checking.
  432. `-fthis-is-variable'
  433.      Permit assignment to `this'.  The incorporation of user-defined
  434.      free store management into C++ has made assignment to `this' an
  435.      anachronism.  Therefore, by default it is invalid to assign to
  436.      `this' within a class member function; that is, GNU C++ treats the
  437.      type of `this' in a member function of class `X' to be `X *const'.
  438.      However, for backwards compatibility, you can make it valid with
  439.      `-fthis-is-variable'.
  440. `-nostdinc++'
  441.      Do not search for header files in the standard directories
  442.      specific to C++, but do still search the other standard
  443.      directories.  (This option is used when building libg++.)
  444. `-traditional'
  445.      For C++ programs (in addition to the effects that apply to both C
  446.      and C++), this has the same effect as `-fthis-is-variable'.  *Note
  447.      Options Controlling C Dialect: C Dialect Options.
  448.    In addition, these optimization, warning, and code generation options
  449. have meanings only for C++ programs:
  450. `-fno-default-inline'
  451.      Do not assume `inline' for functions defined inside a class scope.
  452.      *Note Options That Control Optimization: Optimize Options.
  453. `-Wenum-clash'
  454. `-Woverloaded-virtual'
  455. `-Wtemplate-debugging'
  456.      Warnings that apply only to C++ programs.  *Note Options to
  457.      Request or Suppress Warnings: Warning Options.
  458. `+eN'
  459.      Control how virtual function definitions are used, in a fashion
  460.      compatible with `cfront' 1.x.  *Note Options for Code Generation
  461.      Conventions: Code Gen Options.
  462. File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
  463. Options to Request or Suppress Warnings
  464. =======================================
  465.    Warnings are diagnostic messages that report constructions which are
  466. not inherently erroneous but which are risky or suggest there may have
  467. been an error.
  468.    You can request many specific warnings with options beginning `-W',
  469. for example `-Wimplicit' to request warnings on implicit declarations.
  470. Each of these specific warning options also has a negative form
  471. beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
  472. This manual lists only one of the two forms, whichever is not the
  473. default.
  474.    These options control the amount and kinds of warnings produced by
  475. GNU CC:
  476. `-fsyntax-only'
  477.      Check the code for syntax errors, but don't do anything beyond
  478.      that.
  479.      Inhibit all warning messages.
  480. `-Wno-import'
  481.      Inhibit warning messages about the use of `#import'.
  482. `-pedantic'
  483.      Issue all the warnings demanded by strict ANSI standard C; reject
  484.      all programs that use forbidden extensions.
  485.      Valid ANSI standard C programs should compile properly with or
  486.      without this option (though a rare few will require `-ansi').
  487.      However, without this option, certain GNU extensions and
  488.      traditional C features are supported as well.  With this option,
  489.      they are rejected.
  490.      `-pedantic' does not cause warning messages for use of the
  491.      alternate keywords whose names begin and end with `__'.  Pedantic
  492.      warnings are also disabled in the expression that follows
  493.      `__extension__'.  However, only system header files should use
  494.      these escape routes; application programs should avoid them.
  495.      *Note Alternate Keywords::.
  496.      This option is not intended to be useful; it exists only to satisfy
  497.      pedants who would otherwise claim that GNU CC fails to support the
  498.      ANSI standard.
  499.      Some users try to use `-pedantic' to check programs for strict ANSI
  500.      C conformance.  They soon find that it does not do quite what they
  501.      want: it finds some non-ANSI practices, but not all--only those
  502.      for which ANSI C *requires* a diagnostic.
  503.      A feature to report any failure to conform to ANSI C might be
  504.      useful in some instances, but would require considerable
  505.      additional work and would be quite different from `-pedantic'.  We
  506.      recommend, rather, that users take advantage of the extensions of
  507.      GNU C and disregard the limitations of other compilers.  Aside
  508.      from certain supercomputers and obsolete small machines, there is
  509.      less and less reason ever to use any other C compiler other than
  510.      for bootstrapping GNU CC.
  511. `-pedantic-errors'
  512.      Like `-pedantic', except that errors are produced rather than
  513.      warnings.
  514.      Print extra warning messages for these events:
  515.         * A nonvolatile automatic variable might be changed by a call to
  516.           `longjmp'.  These warnings as well are possible only in
  517.           optimizing compilation.
  518.           The compiler sees only the calls to `setjmp'.  It cannot know
  519.           where `longjmp' will be called; in fact, a signal handler
  520.           could call it at any point in the code.  As a result, you may
  521.           get a warning even when there is in fact no problem because
  522.           `longjmp' cannot in fact be called at the place which would
  523.           cause a problem.
  524.         * A function can return either with or without a value.
  525.           (Falling off the end of the function body is considered
  526.           returning without a value.)  For example, this function would
  527.           evoke such a warning:
  528.                foo (a)
  529.                {
  530.                  if (a > 0)
  531.                    return a;
  532.                }
  533.         * An expression-statement contains no side effects.
  534.         * An unsigned value is compared against zero with `>' or `<='.
  535.         * A comparison like `x<=y<=z' appears; this is equivalent to
  536.           `(x<=y ? 1 : 0) <= z', which is a different interpretation
  537.           from that of ordinary mathematical notation.
  538.         * Storage-class specifiers like `static' are not the first
  539.           things in a declaration.  According to the C Standard, this
  540.           usage is obsolescent.
  541.         * An aggregate has a partly bracketed initializer.  For
  542.           example, the following code would evoke such a warning,
  543.           because braces are missing around the initializer for `x.h':
  544.                struct s { int f, g; };
  545.                struct t { struct s h; int i; };
  546.                struct t x = { 1, 2, 3 };
  547. `-Wimplicit'
  548.      Warn whenever a function or parameter is implicitly declared.
  549. `-Wreturn-type'
  550.      Warn whenever a function is defined with a return-type that
  551.      defaults to `int'.  Also warn about any `return' statement with no
  552.      return-value in a function whose return-type is not `void'.
  553. `-Wunused'
  554.      Warn whenever a local variable is unused aside from its
  555.      declaration, whenever a function is declared static but never
  556.      defined, whenever a label is declared but not used, and whenever a
  557.      statement computes a result that is explicitly not used.
  558. `-Wswitch'
  559.      Warn whenever a `switch' statement has an index of enumeral type
  560.      and lacks a `case' for one or more of the named codes of that
  561.      enumeration.  (The presence of a `default' label prevents this
  562.      warning.)  `case' labels outside the enumeration range also
  563.      provoke warnings when this option is used.
  564. `-Wcomment'
  565.      Warn whenever a comment-start sequence `/*' appears in a comment.
  566. `-Wtrigraphs'
  567.      Warn if any trigraphs are encountered (assuming they are enabled).
  568. `-Wformat'
  569.      Check calls to `printf' and `scanf', etc., to make sure that the
  570.      arguments supplied have types appropriate to the format string
  571.      specified.
  572. `-Wchar-subscripts'
  573.      Warn if an array subscript has type `char'.  This is a common cause
  574.      of error, as programmers often forget that this type is signed on
  575.      some machines.
  576. `-Wuninitialized'
  577.      An automatic variable is used without first being initialized.
  578.      These warnings are possible only in optimizing compilation,
  579.      because they require data flow information that is computed only
  580.      when optimizing.  If you don't specify `-O', you simply won't get
  581.      these warnings.
  582.      These warnings occur only for variables that are candidates for
  583.      register allocation.  Therefore, they do not occur for a variable
  584.      that is declared `volatile', or whose address is taken, or whose
  585.      size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
  586.      structures, unions or arrays, even when they are in registers.
  587.      Note that there may be no warning about a variable that is used
  588.      only to compute a value that itself is never used, because such
  589.      computations may be deleted by data flow analysis before the
  590.      warnings are printed.
  591.      These warnings are made optional because GNU CC is not smart
  592.      enough to see all the reasons why the code might be correct
  593.      despite appearing to have an error.  Here is one example of how
  594.      this can happen:
  595.           {
  596.             int x;
  597.             switch (y)
  598.               {
  599.               case 1: x = 1;
  600.                 break;
  601.               case 2: x = 4;
  602.                 break;
  603.               case 3: x = 5;
  604.               }
  605.             foo (x);
  606.           }
  607.      If the value of `y' is always 1, 2 or 3, then `x' is always
  608.      initialized, but GNU CC doesn't know this.  Here is another common
  609.      case:
  610.           {
  611.             int save_y;
  612.             if (change_y) save_y = y, y = new_y;
  613.             ...
  614.             if (change_y) y = save_y;
  615.           }
  616.      This has no bug because `save_y' is used only if it is set.
  617.      Some spurious warnings can be avoided if you declare all the
  618.      functions you use that never return as `volatile'.  *Note Function
  619.      Attributes::.
  620. `-Wparentheses'
  621.      Warn if parentheses are omitted in certain contexts, such as when
  622.      there is an assignment in a context where a truth value is
  623.      expected, or when operators are nested whose precedence people
  624.      often get confused about.
  625. `-Wenum-clash'
  626.      Warn about conversion between different enumeration types.  (C++
  627.      only).
  628. `-Wtemplate-debugging'
  629.      When using templates in a C++ program, warn if debugging is not yet
  630.      fully available (C++ only).
  631. `-Wall'
  632.      All of the above `-W' options combined.  These are all the options
  633.      which pertain to usage that we recommend avoiding and that we
  634.      believe is easy to avoid, even in conjunction with macros.
  635.    The remaining `-W...' options are not implied by `-Wall' because
  636. they warn about constructions that we consider reasonable to use, on
  637. occasion, in clean programs.
  638. `-Wtraditional'
  639.      Warn about certain constructs that behave differently in
  640.      traditional and ANSI C.
  641.         * Macro arguments occurring within string constants in the
  642.           macro body.  These would substitute the argument in
  643.           traditional C, but are part of the constant in ANSI C.
  644.         * A function declared external in one block and then used after
  645.           the end of the block.
  646.         * A `switch' statement has an operand of type `long'.
  647. `-Wshadow'
  648.      Warn whenever a local variable shadows another local variable.
  649. `-Wid-clash-LEN'
  650.      Warn whenever two distinct identifiers match in the first LEN
  651.      characters.  This may help you prepare a program that will compile
  652.      with certain obsolete, brain-damaged compilers.
  653. `-Wlarger-than-LEN'
  654.      Warn whenever an object of larger than LEN bytes is defined.
  655. `-Wpointer-arith'
  656.      Warn about anything that depends on the "size of" a function type
  657.      or of `void'.  GNU C assigns these types a size of 1, for
  658.      convenience in calculations with `void *' pointers and pointers to
  659.      functions.
  660. `-Wbad-function-cast'
  661.      Warn whenever a function call is cast to a non-matching type.  For
  662.      example, warn if `int malloc()' is cast to `anything *'.
  663. `-Wcast-qual'
  664.      Warn whenever a pointer is cast so as to remove a type qualifier
  665.      from the target type.  For example, warn if a `const char *' is
  666.      cast to an ordinary `char *'.
  667. `-Wcast-align'
  668.      Warn whenever a pointer is cast such that the required alignment
  669.      of the target is increased.  For example, warn if a `char *' is
  670.      cast to an `int *' on machines where integers can only be accessed
  671.      at two- or four-byte boundaries.
  672. `-Wwrite-strings'
  673.      Give string constants the type `const char[LENGTH]' so that
  674.      copying the address of one into a non-`const' `char *' pointer
  675.      will get a warning.  These warnings will help you find at compile
  676.      time code that can try to write into a string constant, but only
  677.      if you have been very careful about using `const' in declarations
  678.      and prototypes.  Otherwise, it will just be a nuisance; this is
  679.      why we did not make `-Wall' request these warnings.
  680. `-Wconversion'
  681.      Warn if a prototype causes a type conversion that is different
  682.      from what would happen to the same argument in the absence of a
  683.      prototype.  This includes conversions of fixed point to floating
  684.      and vice versa, and conversions changing the width or signedness
  685.      of a fixed point argument except when the same as the default
  686.      promotion.
  687.      Also, warn if a negative integer constant expression is implicitly
  688.      converted to an unsigned type.  For example, warn about the
  689.      assignment `x = -1' if `x' is unsigned.  But do not warn about
  690.      explicit casts like `(unsigned) -1'.
  691. `-Waggregate-return'
  692.      Warn if any functions that return structures or unions are defined
  693.      or called.  (In languages where you can return an array, this also
  694.      elicits a warning.)
  695. `-Wstrict-prototypes'
  696.      Warn if a function is declared or defined without specifying the
  697.      argument types.  (An old-style function definition is permitted
  698.      without a warning if preceded by a declaration which specifies the
  699.      argument types.)
  700. `-Wmissing-prototypes'
  701.      Warn if a global function is defined without a previous prototype
  702.      declaration.  This warning is issued even if the definition itself
  703.      provides a prototype.  The aim is to detect global functions that
  704.      fail to be declared in header files.
  705. `-Wmissing-declarations'
  706.      Warn if a global function is defined without a previous
  707.      declaration.  Do so even if the definition itself provides a
  708.      prototype.  Use this option to detect global functions that are
  709.      not declared in header files.
  710. `-Wredundant-decls'
  711.      Warn if anything is declared more than once in the same scope,
  712.      even in cases where multiple declaration is valid and changes
  713.      nothing.
  714. `-Wnested-externs'
  715.      Warn if an `extern' declaration is encountered within an function.
  716. `-Winline'
  717.      Warn if a function can not be inlined, and either it was declared
  718.      as inline, or else the `-finline-functions' option was given.
  719. `-Woverloaded-virtual'
  720.      Warn when a derived class function declaration may be an error in
  721.      defining a virtual function (C++ only).  In a derived class, the
  722.      definitions of virtual functions must match the type signature of a
  723.      virtual function declared in the base class.  With this option, the
  724.      compiler warns when you define a function with the same name as a
  725.      virtual function, but with a type signature that does not match any
  726.      declarations from the base class.
  727. `-Werror'
  728.      Make all warnings into errors.
  729. File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
  730. Options for Debugging Your Program or GNU CC
  731. ============================================
  732.    GNU CC has various special options that are used for debugging
  733. either your program or GCC:
  734.      Produce debugging information in the operating system's native
  735.      format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
  736.      debugging information.
  737.      On most systems that use stabs format, `-g' enables use of extra
  738.      debugging information that only GDB can use; this extra information
  739.      makes debugging work better in GDB but will probably make other
  740.      debuggers crash or refuse to read the program.  If you want to
  741.      control for certain whether to generate the extra information, use
  742.      `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or
  743.      `-gdwarf' (see below).
  744.      Unlike most other C compilers, GNU CC allows you to use `-g' with
  745.      `-O'.  The shortcuts taken by optimized code may occasionally
  746.      produce surprising results: some variables you declared may not
  747.      exist at all; flow of control may briefly move where you did not
  748.      expect it; some statements may not be executed because they
  749.      compute constant results or their values were already at hand;
  750.      some statements may execute in different places because they were
  751.      moved out of loops.
  752.      Nevertheless it proves possible to debug optimized output.  This
  753.      makes it reasonable to use the optimizer for programs that might
  754.      have bugs.
  755.      The following options are useful when GNU CC is generated with the
  756.      capability for more than one debugging format.
  757. `-ggdb'
  758.      Produce debugging information in the native format (if that is
  759.      supported), including GDB extensions if at all possible.
  760. `-gstabs'
  761.      Produce debugging information in stabs format (if that is
  762.      supported), without GDB extensions.  This is the format used by
  763.      DBX on most BSD systems.  On MIPS and Alpha systems this option
  764.      produces embedded stabs debugging output which is not understood
  765.      by DBX.
  766. `-gstabs+'
  767.      Produce debugging information in stabs format (if that is
  768.      supported), using GNU extensions understood only by the GNU
  769.      debugger (GDB).  The use of these extensions is likely to make
  770.      other debuggers crash or refuse to read the program.
  771. `-gcoff'
  772.      Produce debugging information in COFF format (if that is
  773.      supported).  This is the format used by SDB on most System V
  774.      systems prior to System V Release 4.
  775. `-gxcoff'
  776.      Produce debugging information in XCOFF format (if that is
  777.      supported).  This is the format used by the DBX debugger on IBM
  778.      RS/6000 systems.
  779. `-gxcoff+'
  780.      Produce debugging information in XCOFF format (if that is
  781.      supported), using GNU extensions understood only by the GNU
  782.      debugger (GDB).  The use of these extensions is likely to make
  783.      other debuggers crash or refuse to read the program.
  784. `-gdwarf'
  785.      Produce debugging information in DWARF format (if that is
  786.      supported).  This is the format used by SDB on most System V
  787.      Release 4 systems.
  788. `-gdwarf+'
  789.      Produce debugging information in DWARF format (if that is
  790.      supported), using GNU extensions understood only by the GNU
  791.      debugger (GDB).  The use of these extensions is likely to make
  792.      other debuggers crash or refuse to read the program.
  793. `-gLEVEL'
  794. `-ggdbLEVEL'
  795. `-gstabsLEVEL'
  796. `-gcoffLEVEL'
  797. `-gxcoffLEVEL'
  798. `-gdwarfLEVEL'
  799.      Request debugging information and also use LEVEL to specify how
  800.      much information.  The default level is 2.
  801.      Level 1 produces minimal information, enough for making backtraces
  802.      in parts of the program that you don't plan to debug.  This
  803.      includes descriptions of functions and external variables, but no
  804.      information about local variables and no line numbers.
  805.      Level 3 includes extra information, such as all the macro
  806.      definitions present in the program.  Some debuggers support macro
  807.      expansion when you use `-g3'.
  808.      Generate extra code to write profile information suitable for the
  809.      analysis program `prof'.  You must use this option when compiling
  810.      the source files you want data about, and you must also use it when
  811.      linking.
  812. `-pg'
  813.      Generate extra code to write profile information suitable for the
  814.      analysis program `gprof'.  You must use this option when compiling
  815.      the source files you want data about, and you must also use it when
  816.      linking.
  817.      Generate extra code to write profile information for basic blocks,
  818.      which will record the number of times each basic block is
  819.      executed, the basic block start address, and the function name
  820.      containing the basic block.  If `-g' is used, the line number and
  821.      filename of the start of the basic block will also be recorded.
  822.      If not overridden by the machine description, the default action is
  823.      to append to the text file `bb.out'.
  824.      This data could be analyzed by a program like `tcov'.  Note,
  825.      however, that the format of the data is not what `tcov' expects.
  826.      Eventually GNU `gprof' should be extended to process this data.
  827. `-dLETTERS'
  828.      Says to make debugging dumps during compilation at times specified
  829.      by LETTERS.  This is used for debugging the compiler.  The file
  830.      names for most of the dumps are made by appending a word to the
  831.      source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
  832.      possible letters for use in LETTERS, and their meanings:
  833.     `M'
  834.           Dump all macro definitions, at the end of preprocessing, and
  835.           write no output.
  836.     `N'
  837.           Dump all macro names, at the end of preprocessing.
  838.     `D'
  839.           Dump all macro definitions, at the end of preprocessing, in
  840.           addition to normal output.
  841.     `y'
  842.           Dump debugging information during parsing, to standard error.
  843.     `r'
  844.           Dump after RTL generation, to `FILE.rtl'.
  845.     `x'
  846.           Just generate RTL for a function instead of compiling it.
  847.           Usually used with `r'.
  848.     `j'
  849.           Dump after first jump optimization, to `FILE.jump'.
  850.     `s'
  851.           Dump after CSE (including the jump optimization that sometimes
  852.           follows CSE), to `FILE.cse'.
  853.     `L'
  854.           Dump after loop optimization, to `FILE.loop'.
  855.     `t'
  856.           Dump after the second CSE pass (including the jump
  857.           optimization that sometimes follows CSE), to `FILE.cse2'.
  858.     `f'
  859.           Dump after flow analysis, to `FILE.flow'.
  860.     `c'
  861.           Dump after instruction combination, to the file
  862.           `FILE.combine'.
  863.     `S'
  864.           Dump after the first instruction scheduling pass, to
  865.           `FILE.sched'.
  866.     `l'
  867.           Dump after local register allocation, to `FILE.lreg'.
  868.     `g'
  869.           Dump after global register allocation, to `FILE.greg'.
  870.     `R'
  871.           Dump after the second instruction scheduling pass, to
  872.           `FILE.sched2'.
  873.     `J'
  874.           Dump after last jump optimization, to `FILE.jump2'.
  875.     `d'
  876.           Dump after delayed branch scheduling, to `FILE.dbr'.
  877.     `k'
  878.           Dump after conversion from registers to stack, to
  879.           `FILE.stack'.
  880.     `a'
  881.           Produce all the dumps listed above.
  882.     `m'
  883.           Print statistics on memory usage, at the end of the run, to
  884.           standard error.
  885.     `p'
  886.           Annotate the assembler output with a comment indicating which
  887.           pattern and alternative was used.
  888. `-fpretend-float'
  889.      When running a cross-compiler, pretend that the target machine
  890.      uses the same floating point format as the host machine.  This
  891.      causes incorrect output of the actual floating constants, but the
  892.      actual instruction sequence will probably be the same as GNU CC
  893.      would make when running on the target machine.
  894. `-save-temps'
  895.      Store the usual "temporary" intermediate files permanently; place
  896.      them in the current directory and name them based on the source
  897.      file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
  898.      files `foo.i' and `foo.s', as well as `foo.o'.
  899. `-print-file-name=LIBRARY'
  900.      Print the full absolute name of the library file LIBRARY that
  901.      would be used when linking--and don't do anything else.  With this
  902.      option, GNU CC does not compile or link anything; it just prints
  903.      the file name.
  904. `-print-prog-name=PROGRAM'
  905.      Like `-print-file-name', but searches for a program such as `cpp'.
  906. `-print-libgcc-file-name'
  907.      Same as `-print-file-name=libgcc.a'.
  908.      This is useful when you use `-nostdlib' but you do want to link
  909.      with `libgcc.a'.  You can do
  910.           gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
  911.